package com.zeki.controller;

import com.zeki.HelloService;
import com.zeki.service.SentinelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class ConsumerController {

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/echo-rest/{str}")
    public String echo(@PathVariable String str) {
        return restTemplate.getForObject("http://provider/hello/" + str, String.class);
    }


    @Autowired
    private HelloService helloService;

    @GetMapping("/echo-feign/{str}")
    public String feign(@PathVariable String str) {
        return helloService.hello(str);
    }


    @Autowired
    private SentinelService sentinelService;

    @GetMapping("/hello/sentinel/{name}")
    public String helloSentinel(@PathVariable String name) {
        return sentinelService.helloSentinel(name);
    }
}
